package com.mindainfo.configCenter.base.common;


/**
 * 通用返回对象操作类
 * @author MD-01
 *
 */
public class ResponseFactory {

	public static <T> Response<T> ok(T t,String successMsg){
		Response<T> response = new Response<T>();
		response.setCode(0);
		response.setData(t);
		response.setSuccessMsg(successMsg);
		response.setErrorMsg("");
		return response;
	}
	
	public static <T> Response<T> ok(T t){
		Response<T> response = new Response<T>();
		response.setCode(0);
		response.setData(t);
		response.setSuccessMsg("成功");
		response.setErrorMsg("");
		return response;
	}
	
	public static <T> Response<T> ok(){
		Response<T> response = new Response<T>();
		response.setCode(0);
		response.setData(null);
		response.setSuccessMsg("成功");
		response.setErrorMsg("");
		return response;
	}
	
	public static <T> Response<T> error(String errorMsg){
		Response<T> response = new Response<T>();
		response.setCode(1);
		response.setData(null);
		response.setSuccessMsg("");
		response.setErrorMsg(errorMsg);
		return response;
	}
	
	public static <T> Response<T> serverError(String errorMsg){
		Response<T> response = new Response<T>();
		response.setCode(2);
		response.setData(null);
		response.setSuccessMsg("");
		response.setErrorMsg(errorMsg);
		return response;
	}
	
}


